﻿/**	@file		ali.h
 *	@date		(2007-02-04 18:03:19)/(2009-11-21 00:41:50)
 *-----------------------------------------------------------------------------
 *	\brief		解析器.
 *	@version	1.0.10.19
 *	@author		Nick Shallery	(nicknide@gmail.com)
 *	@copyright	YOU HAVE ALL LEFT WITH THIS CODE WHILE YOU KEEP COMMENT IN EVERY COPY.
 *-----------------------------------------------------------------------------
**/


#if			!defined(__LXUT__ALICE__ALI_H__K_IN_G__)
#define		__LXUT__ALICE__ALI_H__K_IN_G__
//==============================================================================
//--------------------------------------------------------------------------

#if			!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)
	#include	"../../lolix/lolix_macro.h"
#endif	//	!defined(__LOLIX__LOLI_X_MACRO__K_IN_G__)

#if			!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
	#include	"../../lolix/lolix_type.h"
#endif	//	!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)


namespace lxut{	namespace alice{

class LOLIX_NO_VTABLE ali_target
	: public lolix::itf
{
public:
	LOLIX_DECLARE_ITF(lxut::alice::ali_target, lolix::itf, (0x4aa587e2, 0x13d34fee, 0x822c3666, 0x4769143e));
	LOLIX_INTERFACE(lock	, const char*	, (void)const);
	LOLIX_INTERFACE(size	, size_type		, (void)const);
	LOLIX_INTERFACE(write	, size_type		, (const char* bg, const char* ed));
	LOLIX_INTERFACE(clear	, void			, (void));
	LOLIX_INTERFACE(unlock	, void			, (const void*));
};


class ali_base;
class LOLIX_NO_VTABLE  ali_factory
	: public lolix::itf
{
public:
	LOLIX_DECLARE_ITF(lxut::alice::ali_factory, lolix::itf, (0x12c47cbc, 0x0d3147cf, 0x8a20f2a3, 0x3d877b16));
	enum ALI_OBJ_TYPE
	{
		//	$<str(=num)>
		ALI_OBJ_TYPE_FULL			,	//	支持带格式的匹配
		ALI_OBJ_TYPE_LINE			,	//	一行
		ALI_OBJ_TYPE_WHITE_SPACE	,	//	空白+注释符号				"$<white>"
		ALI_OBJ_TYPE_BACKSLASH		,	//	解析以反斜杠表达的多行合并
		ALI_OBJ_TYPE_BLANK		,	//	空白符号					"$<blank>"
		ALI_OBJ_TYPE_COMMENT	,	//	注释						"$<comment>"

		ALI_OBJ_TYPE_IDENTIFIER		,	//	匹配标示符					"$<identifier>"

		ALI_OBJ_TYPE_LITERALS		,	//	值							"$<literal>"
		ALI_OBJ_TYPE_LNTEGER	,	//	整数						"$<int>"
		ALI_OBJ_TYPE_FLOATING	,	//	浮点数						"$<float>"
		ALI_OBJ_TYPE_STRING		,	//	字符串						"$<str>"
		ALI_OBJ_TYPE_CHARACTER	,	//	字符						"$<chr>"

		ALI_OBJ_TYPE_NULL			,	//	结束						"$<null>"
	};

	LOLIX_INTERFACE(create_inst			, lolix::LOLIX_RETNV , (ali_base**, ALI_OBJ_TYPE type));
	LOLIX_INTERFACE(create_ali_target	, lolix::LOLIX_RETNV , (ali_target**));
};


class LOLIX_NO_VTABLE  ali_base
	: public lolix::itf
{
public:
	typedef	ali_factory					factory_type;
	LOLIX_DECLARE_ITF(lxut::alice::ali_base, lolix::itf, (0x8c6c687d, 0x305f4444, 0xb570cb24, 0x4d850ce9));
	LOLIX_INTERFACE(get_type	, factory_type::ALI_OBJ_TYPE, (void)const);
	LOLIX_INTERFACE(clone		, lolix::LOLIX_RETNV		, (ali_base**)const);
	LOLIX_INTERFACE(set_target	, lolix::LOLIX_RETNV		, (ali_target*));
	LOLIX_INTERFACE(get_target	, ali_target*				, (void));
	LOLIX_INTERFACE(try_look	, const char*				, (const char* bg, const char* ed));
};


}}



//lolix::LOLIX_RETNV LxutCreateAliFactor(lxut::alice::ali_factory**, lolix::lolix_inst* lx_inst);


//--------------------------------------------------------------------------
//==============================================================================
#endif	//	!defined(__LXUT__ALICE__ALI_H__K_IN_G__)
